package token

import "time"

type Options struct {
	PrivateKey string
	PublicKey  string
}

type Option func(o *Options)

func WithPrivateKey(key string) Option {
	return func(o *Options) {
		o.PrivateKey = key
	}
}
func WithPublicKey(key string) Option {
	return func(o *Options) {
		o.PublicKey = key
	}
}

func NewOptions(opts ...Option) Options {
	var options Options
	for _, opt := range opts {
		opt(&options)
	}
	return options
}

type GenerateOptions struct {
	Expiry time.Duration
}

type GenerateOption func(o *GenerateOptions)

func NewGenerateOptions(opts ...GenerateOption) GenerateOptions {
	var options GenerateOptions
	for _, o := range opts {
		o(&options)
	}
	//set default Expiry of token
	if options.Expiry == 0 {
		options.Expiry = time.Hour * 24
	}
	return options
}

func WithExpiry(expire time.Duration) GenerateOption {
	return func(o *GenerateOptions) {
		o.Expiry = expire
	}
}
